<?php

namespace app\admin\controller;

use app\BaseController;
use think\facade\Filesystem;

class Upload extends BaseController
{
    public function upload()
    {
        $file = request()->file('file');
        if ($file) {
            // 移动到服务器的上传目录 /public/uploads/ 目录下
            $savename = Filesystem::disk('public')->putFile('uploads', $file);
            return json(['code' => 0, 'msg' => 'success', 'file_path' => 'http://aaaf.soqq.com.cn/storage/' . $savename]);
        } else {
            // 上传错误提示信息
            return json(['code' => -1, 'msg' => 'Upload failed']);
        }
    }

}
